<template>
  <div>
    <div class="login-box">
      <img :src="backgrountImg" alt="" />
      <div class="login-bg">
        <div class="login">
          <div>
            <router-link to="/login">
              <div class="login-login">登录</div>
            </router-link>
            <router-link to="/sign">
              <div class="login-sign">
                <div class="sign-after"></div>
                注册
              </div>
            </router-link>
          </div>
          <div>
            <input type="text" class="username" placeholder="用户账号" />
          </div>
          <div>
            <input type="text" class="username" placeholder="电子邮箱" />
          </div>
          <div>
            <input type="password" class="username" placeholder="用户密码" />
          </div>
          <div>
            <input type="password" class="username" placeholder="确认密码" />
          </div>
          <div class="login-button" @click="clickHandle">注册</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Dialog } from "vant";
export default {
  data() {
    return {
      backgrountImg:
        "http://iwenwiki.com/api/blueberrypai/indexImg/login-back_02.png",
    };
  },
  methods: {
    clickHandle() {
      this.$api.register().then((res) => {
        console.log(res.data);
        if (res.data.success === false) {
          Dialog.alert({
            title: "注册失败!",
            message: res.data.msg,
          }).then(() => {
            // on close
          });
        }
      });
    },
  },
};
</script>

<style lang="less" scoped>
.login-box {
  img {
    width: 100%;
  }
}
.login {
  width: 340px;
  height: 400px;
  position: absolute;
  top: 200px;
  left: 600px;
  background: rgba(0, 0, 0, 0.3);
  margin: 0 auto;
  .login-login {
    width: 145px;
    height: 40px;
    line-height: 40px;
    background: #fff;
    color: #000;
    margin: 20px 10px 20px 20px;
    float: left;
    cursor: pointer;
    position: relative;
  }
  .login-sign {
    float: left;
    width: 145px;
    line-height: 40px;
    height: 40px;
    background: orange;
    color: #fff;
    margin: 20px 10px 20px 0;
    padding: 0;
    cursor: pointer;
    position: relative;
  }
  .login-after,
  .sign-after {
    width: 0;
    height: 0;
    border-top: 10px solid #fff;
    border-bottom: 0;
    border-left: 10px solid rgba(0, 0, 0, 0);
    border-right: 10px solid rgba(0, 0, 0, 0);
    position: absolute;
    bottom: -10px;
    left: 62.5px;
    z-index: 999;
  }
  .sign-after {
    border-top: 10px solid orange;
  }
  .username {
    width: 295px;
    height: 40px;
    margin-bottom: 10px;
    padding-left: 5px;
  }
  .login-button {
    width: 300px;
    height: 40px;
    background: rgb(111, 163, 33);
    color: #fff;
    margin-top: 10px;
    margin-left: 20px;
    line-height: 40px;
    margin-bottom: 10px;
    cursor: pointer;
  }
}
</style>